class Hero:
    def __init__(self,name,hp,power):
        self.name = name
        self.hp = hp
        self.power = power
    def speak(self):
        print(f"欢迎来到英雄联盟，我的名字是{self.name}，我的血量为{self.hp}")
class ApHero(Hero):
    def __init__(self,name,hp,power,mp):
        super().__init__(name,hp,power)
        self.mp = mp
    def speak(self):
        super().speak()
        print(f"我的蓝量为{self.mp}")
    def charm(self):
        if self.mp >= 50:
            self.mp -= 50
            print(f"{self.name}使用魅惑技能")
        else:
            print(f"{self.name}的蓝量不足，无法使用魅惑技能")
class WarriorHero(Hero):
    def __init__(self,name,hp,power,Armor):
        super().__init__(name,hp,power)
        self.Armor = Armor
    def speak(self):
        super().speak()
        print(f"我的护甲={self.Armor}")
def fight(hero1:Hero,hero2:Hero):
    while hero1.hp > 0 and hero2.hp > 0:
        hero1.speak()
        hero2.speak()
        hero1.hp -= hero2.power
        hero2.hp -= hero1.power
        print(f"{hero1.name}剩余血量{hero1.hp}")
        print(f"{hero2.name}剩余血量{hero2.hp}")
        if hero1.hp <= 0:
            print(f"{hero2.name}获胜")
        elif hero2.hp <= 0:
            print(f"{hero1.name}获胜")
        else:
            print("继续战斗")
def test_fight():
    hero1 = ApHero("阿狸",1000,200,500)
    hero2 = WarriorHero("猴子",1200,150,200)
    fight(hero1,hero2)
class HeroFactory:
    @staticmethod
    def create_hero(hero_type, *args):
        if hero_type == "ap":
            return ApHero(*args)
        elif hero_type == "warrior":
            return WarriorHero(*args)
        else:
            return Hero(*args)
if __name__ == '__main__':
    test_fight()